// components/gkToolBarItem/gkToolBarItem.js
Component({
    /**
     * 组件的属性列表
     */
    options:{
        addGlobalClass:true
    },
    properties: {
        icon:{
            type:Object,
            value:{type:'path',path:''}
        },

        text: {
            type:String,
            value:""
        },
        width: {
            type: String,
            value: "86rpx"
        },
        height: {
            type: String,
            value: "86rpx"
        },
        showIcon: {
            type: Boolean,
            value: true
        },
    },

    /**
     * 组件的初始数据
     */
    data: {
        iconWh: 0,
        textHeight: 0
    },

    /**
     * 组件的方法列表
     */
    methods: {
        clicked() {
            this.triggerEvent("itemClick");
        }
    },

    observers: {
        'height': function (height) {
            let iconHeight = height;
            let textHeight = height;
            if (this.data.text) {
                var num = height.replace(/[^\d]/g, " ");
                var unit = height.replace(/[0-9]+/g, "");
                iconHeight = Math.round(num * 0.67).toString() + unit;
            } 
            if (this.data.icon) {
                var num = height.replace(/[^\d]/g, " ");
                var unit = height.replace(/[0-9]+/g, "");
                textHeight = Math.round(num * 0.33).toString() + unit;
              }
            this.setData({
                iconWh:iconHeight,
                textHeight:textHeight
            })
        }
    },
    // lifetimes: {
    //     attached() {
    //         console.log("toolbaritematt")
    //     }
    // }
})